﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Entidades;

namespace InterfaceWinForm
{
    public partial class MenuForm : WindowForm
    {
        public MenuForm()
        {
            InitializeComponent();
            
        }

        private void MenuForm_Shown(object sender, EventArgs e)
        {
            radStatusBarPanelUsuario.Text = "Usuário: " + Usuario.Idusuariostatic;
                   
        }

        private void CarregarMenu(string pMenuItemNome)
        {
            MenuDinamicoForm form = new MenuDinamicoForm(pMenuItemNome, this);
            form.MdiParent = this;
            form.Show();
        }

        private void radMenuItem1_Click(object sender, EventArgs e)
        {
            CarregarMenu(radMenuItem1.Text);
        }

        public void CarregarObjeto(string pObjeto, string pDescricao)
        {
            try
            {
                Type t = System.Reflection.Assembly.GetExecutingAssembly().GetType("InterfaceWinForm" + "." + pObjeto);
                BrowsePadrao form = (BrowsePadrao)Activator.CreateInstance(t);
                form.MdiParent = this ; 
                form.Text = pDescricao;
                form.Show();


            }
            catch (Exception ex)
            {
                MessageBox.Show("Problema ao carregar o objeto " + pDescricao + '\n' + ex.Message);
            }
        }

        private void radMenuItem2_Click(object sender, EventArgs e)
        {
            CarregarMenu(radMenuItem2.Text);
        }

        private void radMenuItem3_Click(object sender, EventArgs e)
        {
            CarregarMenu(radMenuItem3.Text);
        }

     
   }
}

